
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8" />
    <title>抢东西</title>
    <link rel="stylesheet" th:href="@{http://www.ssports.com/app/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.css}" />
    <script th:src="@{http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js}"></script>
    <script th:src="@{http://www.ssports.com/app/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.js}"></script>
    <script th:inline="javascript">
        $(document).ready(function () {
            $('#button1').click(function () {
                var userStr = '';
                var productStr = '';
                $('#userGroup :checkbox:checked').each(function () {
                    userStr += $(this).attr("id") + ",";
                });
                $('#productGroup1 :checkbox:checked').each(function () {
                    productStr += $(this).attr("id") + ",";
                });

                $.ajax({
                    type: "POST",
                    url: "submit3hour",
                    dataType: "json",
                    scriptCharset: 'utf-8',
                    data: { "userStr1": userStr, "product1Box": productStr},
                    success: function (data) {
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
//                $('#userStr1').val(userStr);
//                $("#form1").submit();
            });

            $('#button2').click(function () {
                var userStr = '';
                var productStr = '';
                $('#userGroup :checkbox:checked').each(function () {
                    userStr += $(this).attr("id") + ",";
                });
                $('#productGroup2 :checkbox:checked').each(function () {
                    productStr += $(this).attr("id") + ",";
                });

                $.ajax({
                    type: "POST",
                    url: "submitWednesDay",
                    dataType: "json",
                    scriptCharset: 'utf-8',
                    data: { "userStr2": userStr, "product2Box": productStr},
                    success: function (data) {
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
//                $('#userStr2').val(userStr);
//                $("#form2").submit();
            });

            $('#button3').click(function () {
                var userStr = '';
                var productStr = '';
                $('#userGroup :checkbox:checked').each(function () {
                    userStr += $(this).attr("id") + ",";
                });
                $('#productGroup3 :checkbox:checked').each(function () {
                    productStr += $(this).attr("id") + ",";
                });

                $.ajax({
                    type: "POST",
                    url: "submitQiang",
                    dataType: "json",
                    scriptCharset: 'utf-8',
                    data: { "userStr3": userStr, "product3Box": productStr},
                    success: function (data) {
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
//                $('#userStr2').val(userStr);
//                $("#form2").submit();
            });

            $('#buttonStop').click(function () {
                $.get("stop");
            });

            $('#showLog').click(function () {
                $.ajax({
                    type: "GET",
                    url: "getLogs",
                    dataType: "json",
                    scriptCharset: 'utf-8',
                    success: function (data) {
                        $('#positionWindow p').html(data.data);
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
            });
        });

        var h = [[${hour}]];       //获取当前小时数(0-23)
        var m = [[${minute}]];     //获取当前分钟数(0-59)
        var s = [[${second}]];
        function nowtime() {
            var hour = h + ':'+ m + ':'+ s;
            $("#hour").html(hour);
            s++;
            if (s == 60) {
                m = m + 1;
                s = 0;
            }
        }
        nowtime();
        setInterval(nowtime, 1000);
    </script>
    <style>
        #time{
            text-align: center;
        }
    </style>
</head>
<body>
<div data-role="page" class="jqm-demos" data-quicklinks="true">

    <div role="main" class="ui-content jqm-content">
        <h1>活动平台</h1>
        <fieldset data-role="controlgroup" id="userGroup" >
            <div th:each="user : ${userList}">
                <input type="checkbox" th:name="${user.userId}" th:id="${user.userId}"/>
                <label th:for="${user.userId}" th:text="${user.userName}"></label>
            </div>
        </fieldset>
    </div>

    <div data-demo-html="true">
        <div data-role="tabs" id="tabs">
            <div data-role="navbar">
                <ul>
                    <li><a href="#one" data-ajax="false">下午三点</a></li>
                    <li><a href="#two" data-ajax="false">周三五折</a></li>
                    <li><a href="#three" data-ajax="false">周三</a></li>
                </ul>
            </div>
            <div id="one">
                <form id="form1" action="submit3hour" method="post">
                    <input id="userStr1" name="userStr1" type="hidden"/>
                        <fieldset data-role="controlgroup" id="productGroup1" name="productGroup1" data-iconpos="right">
                            <div th:each="product1 : ${product1List}">
                                <input type="checkbox" th:id="${product1.productNo}" name="product1Box" />
                                <label th:for="${product1.productNo}" th:text="${product1.productName}"></label>
                            </div>
                        </fieldset>
                    <button id="button1" class="ui-btn ui-shadow" type="button">提交</button>
                </form>
            </div>
            <div id="two">
                <form id="form2" action="submitWednesDay" method="post">
                    <input id="userStr2" name="userStr2" type="hidden"/>
                        <fieldset data-role="controlgroup" id="productGroup2" name="productGroup2" data-iconpos="right">
                            <div th:each="product2 : ${product2List}">
                                <input type="checkbox" th:id="${product2.productNo}" name="product1Box"/>
                                <label th:for="${product2.productNo}" th:text="${product2.productName}"></label>
                            </div>
                        </fieldset>
                    <button id="button2" class="ui-btn ui-shadow" type="button">提交</button>
                </form>
            </div>
            <div id="three">
                <form id="form3" action="submitQiang" method="post">
                    <input id="userStr3" name="userStr3" type="hidden"/>
                        <fieldset data-role="controlgroup" id="productGroup3" name="productGroup3" data-iconpos="right">
                            <div th:each="product3 : ${product3List}">
                                <input type="checkbox" th:id="${product3.goodsId}" name="product3Box" />
                                <label th:for="${product3.goodsId}" th:text="${product3.title}"></label>
                            </div>
                        </fieldset>
                    <button id="button3" class="ui-btn ui-shadow" type="button">提交</button>
                </form>
            </div>
        </div>
    </div>
    <div id="time">
        <span id="hour"></span>
    </div>
    <a id="showLog" href="#positionWindow" class="ui-btn ui-shadow" data-rel="popup" data-position-to="window">日志显示</a>
    <div data-role="popup" id="positionWindow" class="ui-content" data-theme="a">
        <p>no log</p>
    </div>
</div>
</body>

</html>

